Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parse-filepath

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-filepath

Parse a filepath into an object, yielding predictable results for basename and extname.

  • 0.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1M
decreased by-59.72%
Maintainers
1
Weekly downloads
 
Created
Source

parse-filepath NPM version

Parse a filepath into an object, yielding predictable results for basename and extname.

Install

Install with npm
npm i parse-filepath --save

Usage

var parsePath = require('parse-filepath');
parsePath('foo/bar/baz/index.md.html');

// returns
{
  name: 'index',
  dirname: 'foo/bar/baz',
  extname: '.md.html',
  basename: 'index.md.html',
  extSegments: ['.md', '.html']
}

Differences from node.js path

Given the following string:

var str = 'foo/bar/baz/quux.min.js';
.basename

Node.js:

  • path.basename(str) => quux.min.js
  • path.basename(str, path.extname(str)) => quux.min whaaaaa!?

parse-filepath:

  • parsePath(str).basename => quux.min.js
  • parsePath(str).name => quux
.extname

Node.js:

  • path.extname(str) => .js

parse-filepath

  • parsePath(str).extname => .min.js
.dotfiles

Given the following string:

var str = 'foo/bar/.dotfile';

Node.js

  • path.basename(str) => .dotfile
  • path.extname(str) => .dotfile

parse-filepath

  • parsePath(str).basename => dotfile
  • parsePath(str).name => dotfile
  • parsePath(str).extname => ''

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license


This file was generated by verb-cli on October 18, 2014.

Keywords

FAQs

Package last updated on 19 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc